VS Code Tasks Chrome

自動開啟瀏覽器來打開指定網址

{
    "label": "Chrome",
    "type": "process",
    "args": ["http://localhost:4000/"],
    "windows": {
        "command": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
    },
    "group":"test",
}

想在build或test的tasks完成後自動打開目標頁面可以加上dependsOn

{
    "label": "Hexo Server",
    "type": "shell",
    "command": "hexo server",       
    "group":"test",
},
{
    "label": "Chrome",
    "type": "process",
    "args": ["http://localhost:4000/"],
    "windows": {
        "command": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
    },
    "group":"test",
},
{
    "label": "Hexo Preview",
    "type": "process",
    "dependsOn": ["Hexo Server","Chrome"],
    "group": {
        "kind": "test",
        "isDefault": true
    }
}

這樣會在Tasks:Hexo Server完成後開啟瀏覽器來看結果